package com.example.HelloSpace.factory;

import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

import com.example.HelloSpace.repository.MissionRepository;
import com.example.HelloSpace.viewmodels.MissionDetailsViewModel;

public class MissionDetailsViewModelFactory implements ViewModelProvider.Factory{
    private final MissionRepository repository;

    public MissionDetailsViewModelFactory(MissionRepository repository) {
        this.repository = repository;
    }

    @Override
    public <T extends ViewModel> T create(Class<T> modelClass) {
        if (modelClass.isAssignableFrom(MissionDetailsViewModel.class)) {
            return (T) new MissionDetailsViewModel(repository);
        }
        throw new IllegalArgumentException("Unknown ViewModel class");
    }
}
